/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-09-29
*/
package com.rzico.order.entity;

import com.alibaba.fastjson.JSON;
import com.rzico.basics.model.ProductArticle;
import com.rzico.basics.model.ProductMeta;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * <pre>
 *   砍价活动数据库对象
 * </pre>
 * @author Rzico Boot
 * @version 1.0
 */
@Data
@JsonIgnoreProperties(value = {"handler"})
@JsonInclude(JsonInclude.Include.NON_NULL)
@Table(name = "wx_bargain_buy")
public class BargainBuy{
    @Id
    @ApiModelProperty(value = "" )
    protected Long id;

    @ApiModelProperty(value = "创建日期" )
    protected java.util.Date createDate;

    @ApiModelProperty(value = "修改日期" )
    protected java.util.Date modifyDate;

    @ApiModelProperty(value = "活动名称" )
    protected String name;

    @ApiModelProperty(value = "开始时间" )
    protected java.util.Date beginDate;

    @ApiModelProperty(value = "结束时间" )
    protected java.util.Date endDate;

    @ApiModelProperty(value = "市场价" )
    protected java.math.BigDecimal marketPrice;

    @ApiModelProperty(value = "活动价" )
    protected java.math.BigDecimal price;

    @ApiModelProperty(value = "商品主图" )
    protected String thumbnail;

    @ApiModelProperty(value = "其他资源({video:视频url,images:[图片url},label:标签属性)" )
    protected String meta;

    @ApiModelProperty(value = "商品详情" )
    protected String content;

    @ApiModelProperty(value = "超时时长(分钟数)" )
    protected Integer duration;

    @ApiModelProperty(value = "期数" )
    protected Integer periodNum;

    @ApiModelProperty(value = "邀请人数" )
    protected Integer bargainNum;

    @ApiModelProperty(value = "机器人数" )
    protected Integer robotNum;

    @ApiModelProperty(value = "返还金币" )
    protected java.math.BigDecimal point;

    @ApiModelProperty(value = "类型（0.超值砍价，1.红包砍价）" )
    protected Integer type;

    @ApiModelProperty(value = "状态（0.待审核，1.进行中, 2.已完成, 3.已关闭）" )
    protected Integer status;

    @JsonIgnore
    @ApiModelProperty(value = "是否删除" ,hidden = true )
    protected Boolean deleted;

    @ApiModelProperty(value = "企业" )
    protected Long enterpriseId;


    @ApiModelProperty(value = "商品明细")
    List<BargainProduct> itemList = new ArrayList<>();

    @ApiModelProperty(value = "每期明细")
    List<BargainPeriod> periodList = new ArrayList<>();

    @ApiModelProperty(value = "商品详情")
    protected ProductArticle article;


    @JsonIgnore
    public ProductArticle getMetaAndContent() {
        ProductArticle article = new ProductArticle();
        article.setContent(getContent());
        if (getMeta()!=null) {
            article.setProductMeta(JSON.parseObject(getMeta(), ProductMeta.class));
        } else {
            article.setProductMeta(new ProductMeta());
        }
        return article;
    }

    public String getStatusDescr() {
        if (getStatus().equals(0)) {
            return "待审核";
        } else
        if (getStatus().equals(1)) {
            return "进行中";
        }  else
        if (getStatus().equals(1)) {
            return "已结束";
        } else {
            return "已关闭";
        }
    }


    public void setStatusDescr(String value) {

    }

}
